<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/store/include/init_store.jsp" %>
<%
	if (!isSeller) {
		response.sendRedirect("/publisher");
		return ;
	}

	HashList code015	= CommonUtil.getCodeList("015");	//판매자구분
	HashList code016	= CommonUtil.getCodeList("016");	//은행
	
	HashMap infos = new HashMap();
	infos.put("publisher_id", session_user_id);
	
	PublisherDAO dao = new PublisherDAO();
	HashList info 	= dao.selectPublisherInfo(infos);
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/home/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#store_main li:nth-child(4)').addClass('on');
		$('#publisher_id').on('focusout', function(){ 
			fnCheckId();
		});
	});

	function fnSubmitForm() 
	{
		if (cfCheckRequired(document.saveForm.publisher_id, "아이디를 입력하세요")
			&& cfCheckLength(document.saveForm.publisher_id, 4, "최소 4글자 이상 입력하세요")
			&& cfCheckRequired(document.saveForm.publisher_pw, "비밀번호를 입력하세요")		
			&& cfCheckLength(document.saveForm.publisher_pw, 4, "최소 4글자 이상 입력하세요")
			&& cfCheckRequired(document.saveForm.publisher_pw_chk, "비밀번호 확인을 입력하세요")	
			&& cfCheckSame(document.saveForm.publisher_pw, document.saveForm.publisher_pw_chk, "비밀번호 확인이 잘못 입력되었습니다.")
			&& cfCheckRequired(document.saveForm.email, "이메일을 입력하세요")		
			&& cfCheckRequired(document.saveForm.hp_no, "연락처를 입력하세요")	
			&& cfCheckRequired(document.saveForm.publisher_name, "사업자명을 입력하세요")		
			&& cfCheckRequired(document.saveForm.publisher_name, "사업자명을 입력하세요")
			&& cfCheckRequired(document.saveForm.biz_no, "사업자번호를 입력하세요")
			&& cfCheckRequired(document.saveForm.ceo_name, "대표자명을 입력하세요")
			&& cfCheckRequired(document.saveForm.office_address, "사업장 주소를 입력하세요")
			&& cfCheckRequired(document.saveForm.biz_kind, "업태를 입력하세요")
			&& cfCheckRequired(document.saveForm.biz_item, "종목을 입력하세요")
			//&& cfCheckRequired(document.saveForm.sales_no, "통신판매업신고번호를 입력하세요")
			//&& cfCheckRequired(document.saveForm.publisher_no, "출판사등록번호를 입력하세요")
			//&& cfCheckRequired(document.saveForm.biz_no_path, "사업자등록증 사본을 첨부하세요")
			//&& cfCheckRequired(document.saveForm.sales_no_path, "통신판매업신고증 사본을 첨부하세요")
		)
		{
			return true;
		}
		
		return false;
	}
	
	function fnCheckId() {
		var result = false;
		$.ajax({
			url: './checkPublisher.jsp?publisher_id=' + document.saveForm.publisher_id.value,
			type: "POST",
		    dataType: 'json',//html,text,json
		    error: function(data, status, err){
		    	alert(err);
		    },
			success: function(data){
				if (data.result == false) {
					$('#check_id').show();	
					document.saveForm.publisher_id.focus();
				} else {
					$('#check_id').hide();	
				}
		    }
		});	
		
		return result;
	}
	</script>
</head>
<body>
	<div id="wrap">
		<%@ include file="/publisher/include/header.jsp"  %>
		
		<div id="contents">
			<h2>발행자정보</h2>
			<div id="regist">
            	<form name="saveForm" id="saveForm" method="post" action="./publisherSave.do" enctype="multipart/form-data" onsubmit="return fnSubmitForm()">
					<input type="hidden" name="returnUrl" id="returnUrl" value=""/>
					<input type="hidden" name="job_type" value="U"/>
					<input type="hidden" name="publisher_id" value="<%= info.get("publisher_id",0) %>"/>
					
					<p class="title">기본정보</p>
					
					
					<div>
						<h3>* 아이디</h3>
						<%= info.get("publisher_id",0) %>
					</div>
					<div>
						<h3>* 비밀번호</h3>
						<input type="password" class="text" name="publisher_pw" id="publisher_pw" maxlength="12" value="" />
						<label class="remark">4~12글자를 사용하세요.</label>
					</div>
					<div>
						<h3>* 비밀번호 확인</h3><input type="password" class="text" name="publisher_pw_chk" id="publisher_pw_chk" maxlength="12" value="" />
					</div>
					<div>
						<h3>* 이메일</h3><input type="text" class="text" name="email" id="email" maxlength="255" value="<%= info.get("email",0) %>"/>
					</div>
					<div>
						<h3>* 연락처</h3><input type="text" class="text" name="hp_no" id="hp_no" maxlength="255" value="<%= info.get("hp_no",0) %>"/>
					</div>
					
					
					<p class="title">사업자정보</p>
					
					<div>
						<h3>* 사업자(법인)명</h3><input type="text" class="text" name="publisher_name" id="publisher_name" value="<%= info.get("publisher_name",0) %>"/>
					</div>
					<div>
						<h3>* 사업자번호</h3><input type="text" class="text" name="biz_no" maxlength="12" value="<%= info.get("biz_no",0) %>" />
						<input type="radio"  name="biz_gubn" id="biz_gubn0" value="B" <%= StringUtil.checked("B", info.get("biz_gubn",0)) %> /><label class="pl2 mr10" for="biz_gubn0">개인</label>
						<input type="radio"  name="biz_gubn" id="biz_gubn1" value="P" <%= StringUtil.checked("P", info.get("biz_gubn",0)) %> /><label class="pl2 mr10" for="biz_gubn1">법인</label>
					</div>
					<div>
						<h3>* 대표자명</h3><input type="text" class="text" name="ceo_name" maxlength="100" value="<%= info.get("ceo_name",0) %>" />
					</div>
					<div>
						<h3>* 사업장 주소</h3><input type="text" class="text w600" name="office_address" maxlength="100" value="<%= info.get("office_address",0) %>" />
					</div>
					<div> 
						<h3>* 업태 / 종목</h3>
						<input type="text" class="text w100" name="biz_kind" value="<%= info.get("biz_kind",0) %>" /> /
						<input type="text" class="text w100" name="biz_item" value="<%= info.get("biz_item",0) %>" />
					</div>
					<div>
						<h3>통신판매신고번호</h3><input type="text" class="text" name="sales_no" value="<%= info.get("sales_no",0) %>" />
					</div>
					<div>
						<h3>출판사등록번호</h3>
						<input type="text" class="text" name="publisher_no" value="<%= info.get("publisher_no",0) %>" />
					</div>
					<div>
						<h3>전자세금계산서 수신 이메일</h3><input type="text" class="text w280" name="biz_email" value="<%= info.get("biz_email",0) %>" />
					</div>
					<div>
						<h3>계좌번호</h3>
						<select name="bank_code">
		       			<%= StringUtil.makeOption(code016, info.get("bank_code",0)) %>
		       			</select>
		       			<input type="text" class="text" name="account_no" id="account_no" maxlength="255" value="<%= info.get("account_no",0) %>" />
					</div>
					<div>
						<h3>홈페이지</h3><input type="text" class="text w280" name="homepage_url"  value="<%= info.get("homepage_url",0) %>" />
					</div>
					
					<div></div>
					
					<p class="title">첨부서류</p>
					
					<div>
						<h3>사업자등록증사본</h3> 
						<input type="file" class="file" name="biz_no_path" /> 
					<%	if (!"".equals(info.get("biz_no_path",0))) { %>
							<a href="/common/download_file.jsp?file_dir=<%= info.get("biz_no_path",0) %>">다운로드</a>
					<%	} %>
					</div>
					<div>
						<h3>통신판매신고증사본</h3>
						<input type="file" class="file" name="sales_no_path" /> 
					<%	if (!"".equals(info.get("sales_no_path",0))) { %>
							<a href="/common/download_file.jsp?file_dir=<%= info.get("sales_no_path",0) %>">다운로드</a>
					<%	} %>
					</div>
					<div>
						<h3>사업자(법인) 명의의 통장사본</h3>
						<input type="file" class="file" name="account_no_path" />
					<%	if (!"".equals(info.get("account_no_path",0))) { %> 
							<a href="/common/download_file.jsp?file_dir=<%= info.get("account_no_path",0) %>">다운로드</a>
					<%	} %>
					</div>
					
					<br/>
					<div>
						<h3>&nbsp;</h3>
						<button id="login_btn" class="btn" title="수정하기">수정하기</button>
					</div>
				</form>
				
			</div>
			
             
		</div>
		
		<%@ include file="/publisher/include/footer.jsp"  %>		
	</div>

</body>
</html>
